﻿using DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DevMy.PublicSetUp
{
    public class Class_ChartControl
    {
        public void SetChartControl(ChartControl chartControl, string Text, Series[] series)
        {
            chartControl.BorderOptions.Thickness = 10;
            chartControl.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.True;
            chartControl.DataBindings = null;
            chartControl.Legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.Left;
            chartControl.Legend.AlignmentVertical = DevExpress.XtraCharts.LegendAlignmentVertical.TopOutside;
            chartControl.Legend.Direction = DevExpress.XtraCharts.LegendDirection.LeftToRight;
            chartControl.Legend.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            chartControl.Legend.Name = "Default Legend";
            chartControl.Legend.UseCheckBoxes = true;
            if (series != null)
            {
                chartControl.SeriesSerializable = series;
            }
            DevExpress.XtraCharts.ChartTitle chartTitle3 = new DevExpress.XtraCharts.ChartTitle();
            chartTitle3.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Bottom;
            chartTitle3.Text = Text;
            chartControl.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] {
            chartTitle3});
            SwiftPlotDiagram diagram = chartControl.Diagram as SwiftPlotDiagram;
            diagram.AxisX.GridLines.Visible = true;
            diagram.AxisX.Label.TextPattern = "{A:hh:mm}";
            diagram.AxisX.Title.Text = "时间";
            diagram.AxisX.VisibleInPanesSerializable = "-1";
            diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Minute;
            diagram.AxisY.Interlaced = true;
            diagram.AxisY.Title.Text = "数值";
            diagram.AxisY.VisibleInPanesSerializable = "-1";
            diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false;
            diagram.Margins.Right = 15;
        }

    }
}
